<?php
try{
	include '../ini.php';
    include '../classes/xl_languages.php';
    $dt_xl_languages=new xl_languages;
    if(isset($_GET['languages'])){
        $check_lang=$dt_xl_languages->check_lang($_GET['languages']);
        if($check_lang == NULL ){
            throw new Exception('Không tồn tại mã này!!!');
        }
    }else{
        $_GET['languages']='';
    }
    $list_lang=$dt_xl_languages->list_lang();
    $show_table=$dt_xl_languages->show_table();
    if(isset($_GET['list_table'])){
        $select_table=$dt_xl_languages->select_from($_GET['list_table']);
        $dt_smarty->assign('select_table',$select_table);
    }else{
        $_GET['list_table']='';
    }
    $select_table=$dt_xl_languages->select_from($_GET['list_table']);
    $dt_smarty->assign('select_table',$select_table);
    $dt_smarty->assign('show_table',$show_table);
    $dt_smarty->assign('list_lang',$list_lang);
    $check_lang=$dt_xl_languages->check_lang($_GET['languages']);
    $dt_smarty->assign('check_lang',$check_lang);
	$contenForLayout=$dt_smarty->fetch('languages/translation_list.tpl');
	$dt_smarty->assign('contenForLayout',$contenForLayout);
	$dt_smarty->assign('titleForLayout','Danh sách ngôn ngữ cần dịch');
	$dt_smarty->display('layout/defaults.tpl');
    $dbh=NULL;
} catch(Exception $e){
    $dbh=NULL;
	$_SESSION['msg']=$e->getMessage();
	$_SESSION['type_msg']='error';
    if(empty($_SERVER['HTTP_REFERER'])){
        header('Location: translation_list.php');
    }else{
        header('Location:'.$_SERVER['HTTP_REFERER']);
    }
    
}
